package com.purchase.order.controller;

import com.purchase.common.annotation.Log;
import com.purchase.common.core.domain.AjaxResult;
import com.purchase.common.core.page.TableDataInfo;
import com.purchase.common.enums.BusinessType;
import com.purchase.manage.damian.OrderList;
import com.purchase.order.domain.OrderEvaluate;
import com.purchase.order.service.ICompanyTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author oyi46
 * @version 1.0
 * Create by 2023/7/24 9:31
 */

@RestController
@RequestMapping("/type")
public class CompanyTypeController {

    @Autowired
    ICompanyTypeService companyTypeService;

    @PreAuthorize("@ss.hasPermi('purchase:purchase:insert')")
    @Log(title = "添加公司种类 ", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult addtype(Long typeId,String name) {
        companyTypeService.insertType(typeId,name);
        return AjaxResult.success("添加成功");
    }

    @PreAuthorize("@ss.hasPermi('purchase:purchase:insert')")
    @Log(title = "删除公司种类 ", businessType = BusinessType.DELETE)
    @DeleteMapping
    public AjaxResult deleteType(Long id) {
       companyTypeService.deleteType(id);
        return AjaxResult.success("删除成功");
    }


    @PostMapping("/list")
    public AjaxResult typeList(Long typeId) {
        return AjaxResult.success(companyTypeService.typeList(typeId));
    }
    @PostMapping("/alllist")

    public AjaxResult typeLista() {

        return AjaxResult.success(companyTypeService.getall());
    }

}
